package com.zjw.socket.demo.starter.core;

import com.zjw.socket.demo.starter.core.ioc.IOCScope;
import com.zjw.socket.demo.starter.plugin.PluginDispatcher;
import com.zjw.socket.demo.starter.service.ServiceDispatcher;
import io.vertx.core.Vertx;

public class IOCApplication {

  public static void run(Class<?> rootClass) {
    Reflector.attachApplication(rootClass);
    /*创建唯一app*/
    Vertx vertx = Vertx.vertx();
    Reflector.attachVertx(vertx);

    /*启动服务*/
    ServiceDispatcher.dispatchService(vertx);

    PluginDispatcher.dispatchPlugin();

    if (Reflector.openIOC) {
      IOCScope.globalScope.refresh(Reflector.PROJECT_ROOT_PACKAGE_NAME);
    }
  }
}
